//
//  LDMyResumeCellAvatarInAll.swift
//  DingDongZP
//
//  Created by LeMac on 16/12/27.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class LDMyResumeCellAvatarInAll: LDMyResumeBaseCellInAll {

    var headImg:UIImageView?
    var headImgTitle:UILabel?
    private let headH:CGFloat = 66
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupView()
    }
    
    //更新
    override func updateView() {
        
        super.updateView()
        let url = NSURL.init(string: LDCommentAPI.getPicApi(model?.logo ?? ""))
        headImg?.sd_setImageWithURL(url, placeholderImage: UIImage(named: "common_avatar"))
    }
    
    func setupView() {
        
        
        title = "个人头像"
        isHiddenEditBtn = true
        editBtn?.removeFromSuperview()
        
        headImg = UIImageView.setImageView(headH/2)  //init(image: UIImage.init(named: "avatar_default"), highlightedImage: nil)
//        headImg?.image = UIImage.init(named: "common_avatar")
        
        headImgTitle = UILabel.setDetailsLab("点击更换", fontSize: 14, titleColor: LDFontColor.LightGray, Alignment: .Center)
        headImgTitle?.userInteractionEnabled = true
        headImgTitle?.bk_whenTapped({
            
            DDEditMineInfoViewController.checkAvatar()
        })
        
        bgView!.addSubview(headImg!)
        bgView!.addSubview(headImgTitle!)
        
        headImg?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(LDMargin_V*3)
            make.centerX.equalTo(self)
            make.size.equalTo(CGSizeMake(headH, headH))
        })
        
        headImgTitle?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(headImg!.snp_bottom).offset(LDMargin_V*2)
            make.left.right.equalTo(0)
            make.height.equalTo(LDMargin_V*4)
        })
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
